package com.relytosoft.mizar.media.display.services.consumer;

import com.relytosoft.mizar.media.external.api.display.service.PresetManagementService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 预置点队列消费者
 *
 * @author hj
 * @version 1.0
 * @date 2022/4/13 18:02
 * @ClassName PresetConsumer
 */
@Component
public class PresetConsumer {
    @Resource
    private PresetManagementService presetManagementService;

    protected Logger log = LoggerFactory.getLogger(this.getClass());
//    @KafkaListener(id = DisplayMqIdConstant.PRESET_ID,topics = MediaMqConstants.DISPLAY_PRESET_TOPIC,containerFactory = "singleContainerFactory")
//    public void processSingleMessage(ConsumerRecord<?, ?> record, Acknowledgment ack) {
//        try {
//            KafkaOpMsg kafkaOpMsg = JSON.parseObject(record.value().toString(), KafkaOpMsg.class);
//            PresetDto dto = JSON.parseObject(kafkaOpMsg.getData(), PresetDto.class);
//            switch (kafkaOpMsg.getOpType()) {
//                case INSERT:
//                    presetManagementService.addPreset(dto);
//                    break;
//                case UPDATE:
//                    presetManagementService.updatePreset(dto);
//                    break;
//                case DELETE:
//                    presetManagementService.deletePreset(dto);
//                    break;
//                default:
//            }
//            log.info("线程:{} 消费->{}", Thread.currentThread(), kafkaOpMsg.getOpType());
//            ack.acknowledge();
//        } catch (Exception e) {
//            log.error(e.getMessage());
//        }
//    }
}
